const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// 在webpack.config.js中使用的模块化语法是commonJS模块化语法
const {resolve} = require('path');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
module.exports = {
    // 入口
    entry:'./src/index.js',
    // 出口
    output:{
        filename:'./zihao.js',//输出的文件的名字
        path:resolve(__dirname,'build')//...webpack-2203/buid/zihao.js
    },
    mode:'development',//开发环境
    plugins:[
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            template:'index.html',
            filename:'index.html',
            minify:{
                removeComments:true,
                collapseWhitespace:true
            }
        }),
        // new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin()

    ],
    devServer:{
        contentBase:resolve(__dirname,'build'),
        // 端口
        port:3000,
        // 自动打开浏览器
        open:true
    }
}